home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Cool Demos, SDKs, & Tools / Demos⁄Tools⁄Offers / Alpha ƒ / Tcl / Packages / elecBindings.tcl < prev    next >
Text File  |  1999-02-25  |  3KB  |  111 lines

  1. ## -*-Tcl-*-
  2.  # ###################################################################
  3.  #    Vince's    Additions -    an extension package for Alpha
  4.  # 
  5.  #    FILE: "elecBindings.tcl"
  6.  #                       created: 24/7/97 {6:03:56 pm}    
  7.  #                            last update: 25/2/1999 {7:28:40 pm}    
  8.  #    Author:    Vince Darley
  9.  #    E-mail:    <darley@fas.harvard.edu>
  10.  #      mail:    Division of    Applied    Sciences, Harvard University
  11.  #            Oxford Street, Cambridge MA    02138, USA
  12.  #       www:    <http://www.fas.harvard.edu/~darley/>
  13.  #    
  14.  #    Declares all the global variables for the electric procedures,
  15.  #    and sets up bindings, traces,… so it all works.
  16.  # ###################################################################
  17.  ##
  18.  
  19. alpha::extension elecBindings 9.0 {
  20.     ensureset electricBindings 0
  21.     array set keys::specialProcs { 
  22.     "Complete Or Tab" "bind::TabOrComplete"
  23.     "Expand" "bind::Expansion"
  24.     }
  25.     # set up some bindings if they don't exist
  26.     if {![info exists "keys::specialBindings(Expand)"]} {
  27.     set "keys::specialBindings(Expand)" ""
  28.     }
  29.     if {![info exists "keys::specialBindings(Complete Or Tab)"]} {
  30.     set "keys::specialBindings(Complete Or Tab)" ""
  31.     }
  32.     hook::register specialKeys elec::keyBindings
  33. } maintainer {
  34.     "Vince Darley" darley@fas.harvard.edu <http://www.fas.harvard.edu/~darley/>
  35. } uninstall this-file help {file "ElecCompletions Help"}
  36.  
  37. proc elec::presetKeyBindings {set} {
  38.     global keys::specialBindings
  39.     switch -- $set {
  40.     0 {
  41.         array set keys::specialBindings {
  42.         "Next Stop Or Indent" "/c"
  43.         "Complete" "<O/c"
  44.         "Expand" "<O/ "
  45.         "Prev Stop" "<U/c"
  46.         "Real Tab" "<I/c"
  47.         "nth Stop" "<B/c"
  48.         "Clear All Stops" "<U<B/c"
  49.         "Next Stop" ""
  50.         "Complete Or Tab" ""
  51.         }
  52.     }
  53.     1 {
  54.         array set keys::specialBindings {
  55.         "Next Stop Or Indent" ""
  56.         "Complete" ""
  57.         "Expand" "<O/ "
  58.         "Prev Stop" "<U<B/J"
  59.         "Real Tab" "<I/c"
  60.         "nth Stop" "<B/c"
  61.         "Clear All Stops" "<U<B/c"
  62.         "Next Stop" "<B/J"
  63.         "Complete Or Tab" "/c"
  64.         }
  65.     }
  66.     2 {
  67.         array set keys::specialBindings {
  68.         "Next Stop Or Indent" ""
  69.         "Complete" ""
  70.         "Expand" ""
  71.         "Prev Stop" ""
  72.         "Real Tab" ""
  73.         "nth Stop" ""
  74.         "Clear All Stops" ""
  75.         "Next Stop" ""
  76.         "Complete Or Tab" ""
  77.         }
  78.     }
  79.     
  80.     }
  81. }
  82.  
  83. proc elec::keyBindings {} {
  84.     global electricBindings modifiedVars
  85.     
  86.     set l [list {Cmd-tab (invokes), tab + modifiers (moves)} \
  87.       {Tab key (invokes), j + modifiers (moves)} \
  88.       {A 'clean slate' to build a custom keyset}]
  89.     set text [lindex {
  90.     "use 'cmd-Tab' to invoke completions and 'Tab' (+modifiers) to move amongst template stops."
  91.     "use 'Tab' to invoke completions and 'j' (+modifiers) to move amongst template stops."
  92.     "are based upon a user-defined set."
  93.     } $electricBindings]
  94.     set b [dialog::optionMenu \
  95.       "Special keys binding-sets:\r\rYour current key-bindings $text\
  96.       From the pop-up below, you may make adjustments to those bindings,\
  97.       or reset them to one of the standard sets\
  98.       (and then make any desired adjustments)." \
  99.       [concat [list "Adjust current set" "-"] $l] "" 1]
  100.     
  101.     if {$b != 0} {
  102.     set electricBindings [incr b -1]
  103.     elec::presetKeyBindings $electricBindings
  104.     lappend modifiedVars electricBindings
  105.     }
  106.     hook::callAll electricBindings *
  107.     return
  108. }
  109.  
  110.  
  111.